/*
package com.zzyl.nursing.config;

import com.zzyl.nursing.domain.Contract;
import com.zzyl.nursing.mapper.ContractMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.function.Consumer;

@Component
public class ScheduledTasks {
    @Autowired
    private ContractMapper contractMapper;
    @Scheduled(cron = "30 * * * * ?",zone = "Asia/Shanghai")
    public void performTasklam() {
        try {
            List<Contract> contracts = contractMapper.selectList(null);
            contracts.forEach(new Consumer<Contract>(){
                @Override
                public void accept(Contract contract) {
                    LocalDateTime startDate = contract.getStartDate();
                    if(startDate.isAfter(LocalDateTime.now())){
                        contract.setStatus(1);
                    }else{
                        contract.setStatus(0);
                    }
                    contractMapper.updateById(contract);
                }
            });
            System.out.println("定时任务已完成");
        } catch (Exception e) {
            System.out.println(("捕获到了ServiceException异常"));
        }
    }

}
*/
